﻿using HZY.Framework.DependencyInjection;
using Sunny.UI;

namespace WinFormsSprayProcessSCADASystem.Pages
{
    public partial class PageSystemParameterSet : UIPage, IScopedSelfDependency 
    {
        public PageSystemParameterSet()
        {
            InitializeComponent();
            this.VisibleChanged += PageSystemParameterSet_VisibleChanged;
        }

        private void PageSystemParameterSet_VisibleChanged(object? sender, EventArgs e)
        {
            if (this.Visible)
            {
                this.tb_plcVarConfigPath.Text = Globals.PlcVarConfigPath;
            }
        }

        private void txt_Slot_Click(object sender, EventArgs e)
        {

        }

        private void uiLabel8_Click(object sender, EventArgs e)
        {

        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            try
            {
                Globals.PlcVarConfigPath = this.tb_plcVarConfigPath.Text;
                Globals.IniFile.Write("PLC", "path", this.tb_plcVarConfigPath.Text);
                Globals.IniFile.UpdateFile();
                UIMessageTip.ShowOk($"保存成功!");
            }
            catch (Exception ex)
            {
                UIMessageTip.ShowError(ex.Message);
            }
        }
    }
}
